﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MESMian.EntityMapping
{
    public class WorkShopsMapping : IEntityTypeConfiguration<WorkShops>
    {
        public void Configure(EntityTypeBuilder<WorkShops> builder)
        {
            builder.ToTable("WorkShops");
            builder.HasKey(ws => ws.WorkShopId);
            builder.Property(ws => ws.WorkShopId)
                .HasComment("车间主键，自动编号");

            builder.Property(ws => ws.WorkShopName)
                .IsRequired()
                .HasColumnType("varchar(30)")
                .HasComment("车间名称，不能重复");

            builder.Property(ws => ws.WorkShopContactId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("车间负责人，外键（Users）");

            builder.Property(ws => ws.WorkShopCategoryId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("车间类型，外键（WorkShopCategories）");

            builder.Property(ws => ws.Status)
                .IsRequired()
                .HasColumnType("int")
                .HasDefaultValue(0)
                .HasComment("数据状态（0正常，1删除），默认值0");

            builder.Property(ws => ws.CreateUserId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("创建人，外键（Users）");

            builder.Property(ws => ws.CreateTime)
                .IsRequired()
                .HasColumnType("datetime")
                .HasDefaultValueSql("GETDATE()")
                .HasComment("创建时间，默认值为当前时间");

            builder.Property(ws => ws.LastUpdateUserId)
                .HasColumnType("int")
                .HasComment("最后一次修改人，外键（Users）");

            builder.Property(ws => ws.LastUpdateTime)
                .HasColumnType("datetime")
                .HasComment("最后一次修改时间");
        }
    }

}
